package com.example.my_flea_street.service.impl;

import com.example.my_flea_street.Mapper.UserMapper;
import com.example.my_flea_street.bean.Info;
import com.example.my_flea_street.bean.User;
import com.example.my_flea_street.service.UserService;
import com.github.pagehelper.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service(value = "userService")
public class UserServiceImpl implements UserService {

    @Resource
    UserMapper userMapper;

    @Override
    public Page<Info> getAllUser() {
        return userMapper.getAllUser();
    }

    @Override
    public User getUserByPhone(String phone) {
        return userMapper.getUserByPhone(phone);
    }
    @Override
    public int registerToUser(User user) {
        return userMapper.register(user.getName(),user.getPhone(),user.getAge(),user.getSex(),user.getHead(),user.getSchool(),
                user.getInstitute(),user.getIntroduction());
    }
    @Override
    public String getPassword(String phone) {
        return userMapper.getPassword(phone);
    }

    public String getHead(int id) {
        return userMapper.getHead(id);
    }

    public int editUser(int id, String name, String head, int age, String institute, String introduction, String school) {
        return userMapper.editUser(id,name,head,age,institute,introduction,school);
    }
}
